 var echartsPie;  
    var json = [  
                {value:30,name:'人为'},  
                {value:26,name:'误报'},  
                {value:24,name:'红外'},
                {value:30,name:'呼救'},  
                {value:26,name:'硬件故障'} 
                ];  
    var option = {  
            title : {  
                text: '报警类型',  
                // subtext: '独家报道',  
                x:'center',
                 textStyle: {
            fontSize: 18,
            fontWeight: 'bolder',
            color: 'white',
            padding: 5, 
            itemGap: 10,        // 主标题文字颜色
        },
            },  
            tooltip : {  
                trigger: 'item',  
                formatter: "{a} <br/>{b} : {c}次"  
            },  
            legend: {  
                orient : 'vertical',  
                x : 'left',  
                data:['人为','误报','红外','呼救','硬件故障'],
                 textStyle: {
                color: 'white'          // 图例文字颜色
        }
            },  
            toolbox: {  
                show : true,  
                feature : {  
                    mark : {show: true},  
                    dataView : {show: true, readOnly: false},  
                    magicType : {  
                        show: true,   
                        type: ['pie', 'funnel'],  
                        option: {  
                            funnel: {  
                                x: '25%',  
                                width: '50%',  
                                funnelAlign: 'left',  
                                max: 1548  
                            }  
                        }  
                    },  
                    restore : {show: true},  
                    saveAsImage : {show: true}  
                }  
            },  
            calculable : true,  
            series : [  
                {  
                    name:'类型',  
                    type:'pie',  
                    radius : '55%',//饼图的半径大小  
                    center: ['50%', '60%'],//饼图的位置  
                    data:json  
                }  
            ],
            textStyle: {
            fontSize: 18,
            fontWeight: 'bolder',
            color: 'white'          // 主标题文字颜色
        },
        subtextStyle: {
            color: 'white'        // 副标题文字颜色
        }
        };   
      
    echartsPie = echarts.init(document.getElementById('echartsPie'));  
    $(function(){  
        echartsPie.setOption(option);  
          
    });  

    var t = 1000;//控制数字相加时间
    var text_ =20 + Math.round(Math.random() * (1000 - 1));//随机生成数字
    var ctl_id = "shuzi_b";//获取数字页面id
    var Num = 1234;//起始值
    onload = function() {
        Refresh();
        setInterval("Refresh();", t);
    }
    function Refresh() {
        Num += text_;
        document.getElementById(ctl_id).innerHTML = parseFloat(Num).toLocaleString();//给数字负值并加逗号

    }
     optiona = {
    title: {
        x: 'center',
        text: '报警信息',
        // subtext: 'Rainbow bar example',
        link: 'http://echarts.baidu.com/doc/example.html',
        textStyle: {
            fontSize: 18,
            fontWeight: 'bolder',
            color: 'white',
            padding: 5, 
            itemGap: 10,        // 主标题文字颜色
        },
    },
    tooltip: {
        trigger: 'item'
    },
    toolbox: {
        show: true,
        feature: {
            dataView: {show: true, readOnly: false},
            restore: {show: true},
            saveAsImage: {show: true}
        }
    },
    calculable: true,
    grid: {
        borderWidth: 0,
        y: 80,
        y2: 60
    },
    xAxis: [
        {
            type: 'category',
            show: false,
            data: ['人为', '误报', '红外', '呼救', '硬件故障']
        }
    ],
    yAxis: [
        {
            type: 'value',
            show: false
        }
    ],
    series: [
        {
            // name: 'ECharts例子个数统计',
            type: 'bar',
            itemStyle: {
                normal: {
                    color: function(params) {
                        // build a color map as your need.
                        var colorList = [
                          '#C1232B','#B5C334','#FCCE10','#E87C25','#27727B',
                           
                        ];
                        return colorList[params.dataIndex]
                    },
                    label: {
                        show: true,
                        position: 'top',
                        formatter: '{b}\n{c}'
                    }
                }
            },
            data: [120,78,50,40,90],
            markPoint: {
                tooltip: {
                    trigger: 'item',
                    backgroundColor: 'rgba(0,0,0,0)',
                    formatter: function(params){
                        return '<img src="' 
                                + params.data.symbol.replace('image://', '')
                                + '"/>';
                    }
                },
                data: [
                    {xAxis:0, y: 350, name:'人为', symbolSize:20, symbol: 'image://.'},
                    {xAxis:1, y: 350, name:'误报', symbolSize:20, symbol: 'image://.'},
                    {xAxis:2, y: 350, name:'红外', symbolSize:20, symbol: 'image://.'},
                    {xAxis:3, y: 350, name:'燃气', symbolSize:20, symbol: 'image://.'},
                    {xAxis:4, y: 350, name:'硬件故障', symbolSize:20, symbol: 'image://.'}
                ]
            }
        }
    ]
};
     main = echarts.init(document.getElementById('main'));  
    $(function(){  
        main.setOption(optiona);  
          
    });                  